<%@ page language="java" import="com.zjf.entity.*,java.util.*,com.zjf.dao.*,com.zjf.dao.impl.*" pageEncoding="utf-8"%>
<%!
	User mgUser=null;
%>
<%
try{
	int id = Integer.parseInt(request.getParameter("id"));
	User loginUser = (User)session.getAttribute("loginUser");
	UserDao dao= new UserDaoImpl();
	mgUser= dao.queryUser(id);
	if(loginUser==null||id!=loginUser.getId()){
		response.sendRedirect("error.jsp?id=106");
		return;
	}
}catch(NumberFormatException e){
	response.sendRedirect("error.jsp?id=100");
	return;
}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>控制面板</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="style/style.css" />
<script type="text/javascript">
  function cp(){
	var p0 = usermg.pass0.value;
	var p1 = usermg.pass1.value;
	var p2 = usermg.pass2.value;
	if(p0==""&&p1==""&&p2==""){
		return true;
	}
	if(p0.length<4||p1.length<4||p2.length<4){
		alert("密码长度4位以上");
		return false;
	}
	if(p1!=p2){
		alert("两次密码不一致");
		return false;
	}
	return true;
  }
  </script>
  </head>
  
  <body>
    <center>
    <div id="userMg">
      <p><br></p>
      <p bgcolor="#F0F0F0">用户控制面板</p>
      <table width="500" border="1" bordercolor="#CCCCCC">
      <tr bordercolor="#333333" bgcolor="#F0F0F0">用户头像设置</tr>
        <tr>
          <td><img width=100 height=100 src=<%=mgUser.getHeadUrl() %>></img><jsp:include page="upload.htm"></jsp:include></td>
        </tr>
      </table>
	  <form name="usermg" method="post"  action="userModify.do" onSubmit="return cp()">
      
      <table width="500" border="1" bordercolor="#CCCCCC">
      <tr bordercolor="#333333" bgcolor="#F0F0F0">用户资料设置</tr>
        <tr bordercolor="#333333">
          <td>用户ID：</td>
          <td><%=mgUser.getId() %></td>
        </tr>
        <tr>
          <td>用户名:</td>
          <td><%=mgUser.getUsername() %></td>
        </tr>
        <tr>
          <td>用户密码：</td>
          <td>
            <label>
              <input type="password" name="pass0">
            </label>          </td>
        </tr>
        <tr>
          <td>新密码：</td>
          <td>
            <label>
              <input type="password" name="pass1">
            </label>          </td>
        </tr>
        <tr>
          <td>密码确认：</td>
          <td>
            <label>
              <input type="password" name="pass2">
            </label>          </td>
        </tr>
        <tr>
          <td>姓名：</td>
          <td><input type="text" name="name" value=<%=mgUser.getName() %>></td>
        </tr>
        <tr>
          <td >邮箱：</td>
          <td><input type="text" name="email" value=<%=mgUser.getEmail() %>></td>
        </tr>
        <tr>
          <td>权限：</td>
          <td><%=User.permissonName[mgUser.getPermisson()] %></td>
        </tr>
        <tr>
          <td>注册时间：</td>
          <td><%=mgUser.getRegDate() %></td>
        </tr>
        <tr>
          <td>文章数：</td>
          <td><%=mgUser.getArticleNum() %></td>
        </tr>
        <tr>
          <td>评论数：</td>
          <td><%=mgUser.getReviewNum() %></td>
        </tr>
      </table>
	  <input type="submit" name="submit" value="更新"><input name="reset" type="reset" id="reset" value="重置">
	  </form>
      <p>&nbsp;</p>
    </div>
    </center>
    </body>
</html>
